import { payPayTransactions } from "@/config/api";

export function payTransactions(orderId) {
  return payPayTransactions(
    {
      _id: orderId,
    },
    {
      catch: true,
    }
  )
    .then((res) => {
      console.log("获取了支付的数据", res);
      //调用微信官方支付接口弹出付款界面,输入密码扣款
      return new Promise((resolve, reject) => {
        wx.requestPayment({
          provider: "wxpay",
          timeStamp: String(res.data.timeStamp),
          nonceStr: res.data.nonceStr,
          package: res.data.package,
          signType: res.data.signType,
          paySign: res.data.paySign,
          success(result) {
            resolve(result);
          },
          fail(errResult) {
            reject(errResult);
          },
        });
      });
    })
    .catch((err) => {
      return Promise.reject(err);
    });
}
